import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';

import '../common.dart';

class ReleaseCalendar extends StatefulWidget {
  ReleaseCalendar({super.key});
  @override
  State<ReleaseCalendar> createState() => _QGRulePageState();
}

class _QGRulePageState extends State<ReleaseCalendar> {
  var dayGoods = [];

  @override
  void initState() {
    super.initState();

    getData(url: '/index/day_goods').then((res) {
      dayGoods = res;
      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Color(0XFFFFFFFF),
        centerTitle: true,
        title: wText(text: '发售日历', size: 18, bold: true),
        leading: buildBackButton(context),
      ),
      backgroundColor: Color(0xFFFFFFFF),
      body: ListView(
        padding: EdgeInsets.symmetric(horizontal: 15),
        children: [
          for (var item in dayGoods.asMap().entries)
            Container(
              margin: EdgeInsets.only(bottom: 30),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  wText(text: item.value['month'], size: 16, bold: true),
                  SizedBox(height: 10),

                  for (var itemS in item.value['list'].asMap().entries)
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Column(
                          children: [
                            wText(
                              text: itemS.value['day'],
                              size: 20,
                              bold: true,
                            ),
                            wText(text: itemS.value['week'], bold: true),
                          ],
                        ),
                        SizedBox(width: 10),
                        Expanded(
                          child: Column(
                            children: [
                              for (var itemt
                                  in itemS.value['goods'].asMap().entries)
                                Container(
                                  margin: EdgeInsets.only(bottom: 10),
                                  padding: EdgeInsets.symmetric(
                                    horizontal: 10,
                                    vertical: 10,
                                  ),
                                  decoration: BoxDecoration(
                                    color: Color(0XFFF8F9FD),
                                    borderRadius: BorderRadius.circular(10),
                                  ),
                                  child: Row(
                                    children: [
                                      SizedBox(width: 3),
                                      wImage(
                                        url: itemt.value['thumb'],
                                        width: 60,
                                        height: 60,
                                        borderRadius: 8,
                                      ),
                                      SizedBox(width: 10),
                                      Column(
                                        crossAxisAlignment:
                                            CrossAxisAlignment.start,
                                        children: [
                                          Row(
                                            children: [
                                              wText(
                                                text: itemt.value['title'],
                                                size: 14,
                                                bold: true,
                                              ),
                                              setInteger(
                                                itemt.value['vlv'],
                                                w: 14,
                                              ),
                                            ],
                                          ),
                                          wText(
                                            text: itemt.value['copyright'],
                                            color: '878b95',
                                          ),
                                        ],
                                      ),
                                    ],
                                  ),
                                ),
                            ],
                          ),
                        ),
                      ],
                    ),
                ],
              ),
            ),

          // Container(
          //   child: Column(
          //     crossAxisAlignment: CrossAxisAlignment.start,
          //     children: [
          //       wText(text: '2025-7', size: 16, bold: true),
          //       SizedBox(height: 10),
          //       Row(
          //         crossAxisAlignment: CrossAxisAlignment.start,
          //         children: [
          //           Column(
          //             children: [
          //               wText(text: '25', size: 20, bold: true),
          //               wText(text: '周三', bold: true),
          //             ],
          //           ),
          //           SizedBox(width: 10),
          //           Expanded(
          //             child: Container(
          //               padding: EdgeInsets.symmetric(
          //                 horizontal: 10,
          //                 vertical: 10,
          //               ),
          //               decoration: BoxDecoration(
          //                 color: Color(0XFFF8F9FD),
          //                 borderRadius: BorderRadius.circular(10),
          //               ),
          //               child: Row(
          //                 children: [
          //                   SizedBox(width: 3),
          //                   wImage(
          //                     url: 'aaa',
          //                     width: 60,
          //                     height: 60,
          //                     borderRadius: 8,
          //                   ),
          //                   SizedBox(width: 10),
          //                   Column(
          //                     crossAxisAlignment: CrossAxisAlignment.start,
          //                     children: [
          //                       Row(
          //                         children: [
          //                           wText(
          //                             text: '藏品名称二十个字藏品',
          //                             size: 14,
          //                             bold: true,
          //                           ),
          //                           wImage(url: 'lanv', width: 14),
          //                         ],
          //                       ),
          //                       wText(
          //                         text: '来自 Opensea Gathering Team',
          //                         color: '878b95',
          //                       ),
          //                     ],
          //                   ),
          //                 ],
          //               ),
          //             ),
          //           ),
          //         ],
          //       ),
          //     ],
          //   ),
          // ),
        ],
      ),
    );
  }
}
